
<%@page import="com.DBtools"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加学生记录</title>
</head>
<body>
<%
//接收用户参数，主键，标记修改的的记录条件
request.setCharacterEncoding("utf-8");//编码

String TeaId = request.getParameter("TeaId");
String bol = request.getParameter("bol");
System.out.println("bol为"+bol);
String TeaName="",TeaGender="",TeaEmail="",TeaAge="";

/*  方法1，方法2用封装方法
//连接数据库，查询当前记录的数据库中的数据
Class.forName("org.mariadb.jdbc.Driver");
String url = "jdbc:mariadb://localhost:3306/databaseone";
Connection conn = DriverManager.getConnection(url,"root","123456");
Statement stmt = conn.createStatement();
ResultSet  rs=stmt.executeQuery("select * from stu where num="+num); */

ResultSet rs= new DBtools().query("select * from  teacher where TeaId="+TeaId);
if(rs.next()){
	TeaName=rs.getString("TeaName");
	TeaGender=rs.getString("TeaGender");
	TeaEmail=rs.getString("TeaEmail");
	TeaAge=rs.getString("TeaAge");
}
rs.close();
System.out.println("TeaGender为"+TeaGender);
%>
<h3 align="center">教师名单管理</h3>
<hr>
<form action="../TeaOperate" method="post" >
<table>
<tr>
<td>工号</td>
<td><input type="text" name="TeaId"  value="<%=TeaId==null? "":TeaId%>" <% if(bol.equals("1")){out.println("readonly="+"readonly" );}%> ></td>
</tr>
<tr>
<td>姓名</td>
<td><input type="text" name="TeaName" value="<%=TeaName%>" >
</td>
</tr>
<tr>
<td>性别</td>
<td>

 <% if(TeaGender.equals("")){%>
 <select name="TeaGender">
    <option value="男">男</option>
    <option value="女">女</option>
    </select><%}else if(TeaGender.equals("男")){%>
  <select name="TeaGender">
    <option value="<%=TeaGender%>"><%out.println(TeaGender);%></option>
    <option value="女">女</option>
    </select> <%}else{%>
  
   <select name="TeaGender">
    <option value="<%=TeaGender%>"><%out.println(TeaGender);%></option>
    <option value="男">男</option>
    </select><%} %>
   
</td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" name="TeaEmail" value="<%=TeaEmail%>" ></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="TeaAge"  value="<%=TeaAge%>" ></td>
<tr>
<tr>
				<td>学院</td>
				<td><input name="DepName" readonly="readonly"
				<%
				String UserNum=(String)request.getSession().getAttribute("UserNum");
				
				//ResultSet rs = stmt.executeQuery("select * from user where UserNum="+UserNum);  
				
				ResultSet rs2 = new DBtools().query("select * from department where DepNum="+UserNum);  
				
				while(rs2.next()){
					String DepName = rs2.getString("DepName");
					out.println("value="+DepName);
				}
				rs2.close();
				//方1 
				/* stmt.close();
				conn.close();  */
				%>
				>
				</td>
			</tr>

<tr>
<td><input type="submit" name="btn" value="<%=(bol.equals("1")? "修改":"提交" ) %>"></td>
</tr>
</table>
</form>
</body>
<html>
